<?php
    @header("Content-Type:text/html;charset=utf-8");//前端接口转义


    const host="localhost";
    const user="root";
    const pwd="root";
    const dbName="2101";
    $connect=mysqli_connect(host,user,pwd,dbName);
    // print_r($connect);
    if(!$connect){
        exit("数据库连接错误");
    }
    //设置字符串编码（转码设置）
    mysqli_query($connect,"set names utf8");//从数据库取数据时 将编码转为utf-8;

    mysqli_query($connect,"set character set utf-8");//向数据库传入数据  将编码转为utf-8

    $name=$_GET["name"];
    $sqlchar="select * from`study` where name='$name'";
    $result=mysqli_query($connect,$sqlchar);//$connect  连接对象   sql是个sql语句
     
    $item=mysqli_fetch_assoc($result);
    $msg=array();
    if($item){
        $msg["status"]=true;
        $msg["datail"]="ok";
        $msg["data"]=$item;
    }else{
        $msg["status"]=false;
        $msg["datail"]="not found";
        $msg["data"]=null;
    }

    // print_r($item);
    echo json_encode($msg);





?>